package question.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.xuegengwang.xuegengwang.R;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.ArrayList;

import question.bean.QuestionDetailBean;
import view.MyImageLoader;

/**
 * Created by Administrator on 2017/4/10.
 * 问题详情的评论列表
 */

public class QuestionDetailEvaluateAdapter extends BaseAdapter {

    private Context context;
    private ArrayList<QuestionDetailBean.DetailBean.QuestionDetailCommentBean> arrayList;


    public QuestionDetailEvaluateAdapter(Context context, ArrayList<QuestionDetailBean.DetailBean.QuestionDetailCommentBean> arrayList) {
        this.context = context;
        this.arrayList = arrayList;
    }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyEvaluateHolder myHolder;
        if (convertView == null) {
            myHolder = new MyEvaluateHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.volunteer_evaluate_list_item, null);
            myHolder.volunteer_evaluate_item_answer = (TextView) convertView.findViewById(R.id.volunteer_evaluate_item_answer);
            myHolder.volunteer_evaluate_item_icon = (RoundedImageView) convertView.findViewById(R.id.volunteer_evaluate_item_icon);
            myHolder.volunteer_evaluate_item_date = (TextView) convertView.findViewById(R.id.volunteer_evaluate_item_date);
            myHolder.volunteer_evaluate_item_name = (TextView) convertView.findViewById(R.id.volunteer_evaluate_item_name);
            convertView.setTag(myHolder);
        } else {
            myHolder = (MyEvaluateHolder) convertView.getTag();
        }
        myHolder.volunteer_evaluate_item_name.setText(arrayList.get(position).getName());
        MyImageLoader.showImage(arrayList.get(position).getHeadimgurl(), myHolder.volunteer_evaluate_item_icon);
        myHolder.volunteer_evaluate_item_date.setText(arrayList.get(position).getTime());
        myHolder.volunteer_evaluate_item_answer.setText(arrayList.get(position).getContent());
        return convertView;
    }

    class MyEvaluateHolder {
        RoundedImageView volunteer_evaluate_item_icon;
        TextView volunteer_evaluate_item_name;
        TextView volunteer_evaluate_item_date;
        TextView volunteer_evaluate_item_answer;
    }

}
